Imports System.Data
Imports System.Data.SqlClient
Partial Class Client_frmEditProfile
    Inherits System.Web.UI.Page
    Dim _UserId As String
    Dim dt As New DataTable
    Dim _bo As New Bo
    Dim tmpvar As String
    Dim dr As DataRow
    Dim dtCity As New DataTable
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        _UserId = Session("UserId")
        If _UserId = "" Then
            Response.Redirect("frmLogin.aspx")
        End If
        If Not Page.IsPostBack Then
            lblUserId.Text = _UserId
            Call CountryData()
            dt = _bo.getUserDetail(_UserId)
            For Each dr In dt.Rows
                txtFirstName.Text = dr("FirstName").ToString
                txtLastName.Text = dr("LastName").ToString
                txtAddress.Text = dr("Address").ToString
                rdbGender.SelectedValue = dr("Gender").ToString
                ddlCountry.SelectedValue = dr("Country").ToString
                Call StateData()
                Call CityData()
                ddlState.SelectedValue = dr("State").ToString
                ddlCity.SelectedValue = dr("City").ToString
                txtBirthDate.Text = dr("BirthDate")
                txtEmailId.Text = dr("EmailId").ToString
                txtAnniversaryDate.Text = dr("AnniversaryDate").ToString
                txtPhoneNumber.Text = dr("PhoneNumber").ToString
                txtMobileNumber.Text = dr("MobileNumber").ToString
                txtZipcode.Text = dr("ZipCode").ToString
            Next
        End If
    End Sub
    Public Sub CountryData()
        Dim dtCountry As DataTable
        dtCountry = _bo.getcountry()
        ddlCountry.DataSource = dtCountry
        ddlCountry.DataValueField = dtCountry.Columns(0).ToString
        ddlCountry.DataTextField = dtCountry.Columns(1).ToString
        ddlCountry.DataBind()
    End Sub
    Sub StateData()
        Dim dtState As DataTable
        dtState = _bo.getstate(ddlCountry.SelectedValue)
        ddlState.DataSource = dtState
        ddlState.DataValueField = dtState.Columns(1).ToString
        ddlState.DataTextField = dtState.Columns(2).ToString
        ddlState.DataBind()
    End Sub
    Sub CityData()
        Dim dtCity As DataTable
        dtCity = _bo.getCity(ddlState.SelectedValue)
        ddlCity.DataSource = dtCity
        ddlCity.DataValueField = dtCity.Columns(2).ToString
        ddlCity.DataTextField = dtCity.Columns(3).ToString
        ddlCity.DataBind()
    End Sub
    Protected Sub ddlCountry_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlCountry.SelectedIndexChanged
        Call StateData()
        Call CityData()
    End Sub
    Protected Sub ddlState_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlState.SelectedIndexChanged
        Call CityData()
    End Sub

    Protected Sub lnk_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnk.Click
        Session("UserId") = _UserId
        Response.Redirect("frmChangePassword.aspx")
    End Sub

    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        Session("UserId") = _UserId
        Response.Redirect("frmDataList.aspx")
    End Sub

    Protected Sub btnReset_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnReset.Click
        txtFirstName.Text = ""
        txtLastName.Text = ""
        txtAddress.Text = ""
        txtBirthDate.Text = ""
        txtEmailId.Text = ""
        txtAnniversaryDate.Text = ""
        txtPhoneNumber.Text = ""
        txtMobileNumber.Text = ""
        txtZipcode.Text = ""
    End Sub
End Class
